package model.commands.keyboard;

import model.RandomUtils;

public class KeyboardTypeRandomNumber extends KeyboardType {
	private Integer from = null;
	private Integer to = null;

	@Override
	public void execute() {
		try {
			int randomNumber = RandomUtils.getRandomNumber(from, to+1);
			type(String.valueOf(randomNumber));
			propertyChangeSupport.firePropertyChange(EXECUTION_FINISHED, null, this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void setParams(Object[] params) {
		from = ((Integer) params[0]);
		to = ((Integer) params[1]);
		if(from == null){
			from = 0;
		}
		
		if(to == null){
			to = Integer.MAX_VALUE - 1;
		}
	}

	public Integer getFrom() {
		return from;
	}

	public Integer getTo() {
		return to;
	}

	
}
